<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('出库')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <input type="hidden" th:value="${id}" id="kid">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <div class="group-button" id="toolbar">
                    <!--<a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                        <i class="layui-icon">&#x1005;</i> 操作人员
                    </a>-->
                    <a class="layui-btn layui-btn-sm layui-btn-normal edit-btn">
                        <i class="layui-icon">&#x1005;</i> 确认上架
                    </a>
                </div>
                <!--<input id="xssl" type="hidden">
                <input id="pssl" type="hidden">
                <input id="czry" type="hidden">
                <input id="jssl" type="hidden">
                <input id="jsyy" type="hidden">
                <input id="pid" type="hidden">-->
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table1" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

<!--多选操作人员-->
<!--<div style="padding: 0px 15px;" hidden="hidden" id="addfunction">
    <div class="layui-fluid larry-wrapper" >
        <div class="layui-card">
            <form class="layui-form layui-card-header  layui-card-header-auto" id="tiaozhengForm">
                <div class="layui-inline">
                    <label class="layui-form-label">操作人员</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="czren" name="czren"  />
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>-->
</body>
<div th:include="public/public_js::public_js"></div>
<script>
    var xx_number = 0;
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate'], function () {
        window.operateEvent1 = {

            "click #btn_tz1": function (e, value, row, index) {//调整
                tiao(row.id, index);
            }
        }
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;

        var $table = zzpUtils.table({
            elem: '#table1',
            isApi: true,
            uniqueId:"id",
            pagination: true,
            url: '/wmsfailedstorage/getReceiveList?asnId=' + $("#kid").val(),
            columns: [{
                field: '',
                checkbox: true
            },{
                field: 'idex',
                title: 'idex',
                visible:false
            },{
                field: 'nuber',
                title: 'nuber',
                visible:false
            },{
                field: 'show_bh',
                title: '货品编号'
            }, {
                field: 'show_mc',
                title: '货品名称'
            }, {
                field: 'shkwmc',
                title: '收货库位'
            }, {
                field: 'show_hppc',
                title: '批次号'
            }, {
                field: 'show_scrq',
                title: '生产日期'
            }, {
                field: 'sl',
                title: '收货数量'

            }, {
                field: 'sjsl',
                title: '出库数量',
                formatter:operateFormatterNumber,
                editable: {
                    type: 'text',
                    clear: false,
                    validate: function (value) {
                        //alert(value+'==='+xx_number);
                        if (isNaN(value)) return {newValue: 1, msg: '只允许输入数字'};
                        else if (value <=0) return {newValue: 1,msg: '不能输入负数或0'};
                        else if (value <= Number(xx_number)) return {newValue: value};
                        else if (value > Number(xx_number)) return {newValue: xx_number};
                    },
                }

            }],
            onClickRow: function (row, $element, field) {
                xx_number = row.sl;
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }
        });

        function operateFormatterNumber (value,row,index) {
           return row.sl;
        }


        /*顶部按钮确认收货  */
        $(".edit-btn").on('click', function () {
            var $rows = $table.bootstrapTable('getSelections');
            //console.log($rows);
            var id;
            var number=0;
            if ($rows.length > 0) {
                for (var i=0;i<$rows.length;i++){
                    id=$rows[i].id;
                    if ($rows[i].czry==''){
                        number++;
                    }
                }



                if(number>0){
                    layer.msg("您选中的信息有未调整的，请先调整！！！");
                }else{
                    zzpUtils.confirm("是否确定收货", function (index) {
                        zzpUtils.action({
                            url: '/wmsfailedlibrary/add',
                            data: JSON.stringify($rows),
                            success: function (data) {
                                setTimeout(function () {
                                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                    parent.layer.close(index); //再执行关闭
                                    top.layer.msg(data.title);
                                }, 500);
                                // zzpUtils.refreshTable("#table");
                            }, error: function (xhr, textStatus) {
                                console.log(textStatus);
                                console.log(xhr)
                            }
                        })
                    })
                    return false;

                }

            } else {
                layer.msg("请选择一条进行操作");
            }
        })
    });
    function changett(index,sl,id){
        var dongjiedata = $('#dongjieNumber'+index).val();
        if (/^\d+$/.test(dongjiedata)) {
            if (parseInt(dongjiedata) <= parseInt(sl)) {
                $('#dongjieNumber'+index).val(dongjiedata);
            }else{
                $('#dongjieNumber'+index).val(sl);
            }
        }
    }
</script>
</html>